def subsets(nums):
    res = []
    
    def backtrack(index, path):
        res.append(path.copy()) 
       
        for i in range(index, len(nums)):
            path.append(nums[i])    
            backtrack(i + 1, path)   
            path.pop()              
    
    backtrack(0, [])  
    return res
